<?php


class InsStageTable extends Doctrine_Table {

    public static function getInstance() {
        return Doctrine_Core::getTable('InsStage');
    }

    public static function contactInscrit($contactId, $stageId) {
        if (!is_null($contactId) && !empty($contactId)) {
            if (!is_null($stageId) && !empty($stageId)) {
                $recordSet = Doctrine_Query::create()
                                ->from('InsStage')
                                ->where('id_contact = ?', $contactId)
                                ->andWhere('id_stage = ?', $stageId)
                                ->andWhere('deleted_at = ?', null)
                                ->execute();
            } else {
                throw new Exception('stage_id est incorrect');
            }
        } else {
            throw new Exception('contact id est incorrect');
        }

        return $recordSet;
    }
    
    public static function groupeInscrit($groupeId, $stageId) {
        if (!is_null($groupeId) && !empty($groupeId)) {
            if (!is_null($stageId) && !empty($stageId)) {
                $recordSet = Doctrine_Query::create()
                                ->from('InsStage')
                                ->where('id_groupe = ?', $groupeId)
                                ->andWhere('id_stage', $stageId)
                                ->andWhere('deleted_at = ?', null)
                                ->execute();
            } else {
                throw new Exception('stage_id est incorrect');
            }
        } else {
            throw new Exception('groupe id est incorrect');
        }
        return $recordSet;
    }

}